import { getStationNames } from "@/api/dataQuery" 
import { getWorkSummaryInfo } from "@/api/statistics"

export default {
  data() {
    return {
      queryData: {
        station: '',  // 站场名称
        trainNo: '',  // 机车号
        startTime: new Date(new Date().getTime() - 3600 * 1000 * 24),
        endTime: new Date(new Date().getTime()),
        // page: 1,
        // limit: 10
      },
      listLoading: true,
      tableKey: 0,
      currentPage: 1,
      pageSize: 10,
      totalDataLength: 0,
      stationNameOptions: [],
      rcvTableData: [],
      tableHeight: 0
    }
  },
  created() {
  },
  mounted() {
    this.$nextTick(() => {
      // 根据浏览器高度设置初始高度
      this.tableHeight = window.innerHeight - this.$refs.refsTable.$el.offsetTop - 150
      // 监听浏览器高度变化，修改表格高度
      window.onresize = () => {
        this.tableHeight = window.innerHeight - this.$refs.refsTable.$el.offsetTop - 150
      }
    })
  },
  computed: {
  },
  watch: {
    "queryData.startTime": function (newTime, oldTime) {
      if (!newTime) {
        this.queryData.startTime = new Date(new Date().getTime() - 3600 * 1000 * 24)
      }
    },
    "queryData.endTime": function (newTime, oldTime) {
      if (!newTime) {
        this.queryData.endTime = new Date(new Date().getTime())
      }
    }
  },
  methods: {
    async getAllWorkSummaryInfo() {
      this.listLoading = true
      this.globalTableData = []
      // this.queryData.page = this.currentPage
      // this.queryData.limit = this.pageSize
      // const res = await getWorkSummaryInfo(this.queryData)
      // if (res.msg) {
      //   this.$message.info(res.msg)
      // } 
      // this.totalDataLength = res.data.length
      // this.rcvTableData = res.data
      this.listLoading = false
    },
    async getAllStationNames() {
      // this.stationNameOptions = []
      // const res = await getStationNames()
      // if (res.msg) {
      //   this.$message.info(res.msg)
      // } 
      // this.stationNameOptions = res.data
    },
    reset() {
      this.queryData.startTime = new Date(new Date().getTime() - 3600 * 1000 * 24)
      this.queryData.endTime = new Date(new Date().getTime())
      this.queryData.station = ''
      this.queryData.trainNo = ''
      this.getAllWorkSummaryInfos()
    },
    search() {
    },
    handleCurrentChange: function (currentPage) {
      this.currentPage = currentPage;
    },
    handleSizeChange: function (size) {
      this.pageSize = size
    }
  }
}
